#ifndef SERIAL_H_
#define SERIAL_H_


/*
IRQ 3 	Default COM2 and COM4
IRQ 4 	Default COM1 and COM3
*/
/* Serial ports */

#define  COM1  0x3F8  /* IRQ4 */
#define  COM2  0x2F8  /* IRQ3 */
#define  COM3  0x3E8  /* IRQ4 */
#define  COM4  0x2E8  /* IRQ3 */

 /* Registros con codigos relativos a los puertos */

#define IER  1  /* Interrupt Enable Register  (read/write)  */
#define IIR  2  /* Interrupt Identification Register  (read only) */
#define FCR  2  /* FIFO Control Register  (write only)  */               
#define LCR  3  /* Line Control Register  (read/write)  */              
#define MCR  4  /* Modem Control Register (read/write)  */
#define LSR  5  /* Line Status Register   (read only)   */
#define MSR  6  /* Modem Status Register  (read only)   */
#define SPR  7  /* Scratch Pad Register   (read/write   */               
#define	THR  0  /* Transmitter holding register (WO) */ 
#define RBR  0  /* Receiver buffer register (RO) */




/* Algunas constantes */
#define ODD		  			 0x00
#define EVEN 				 0x10    
#define ONE_STOP_BIT		 0x00
#define TWO_STOP_BIT		 0x04
#define BRD          		 0x80  /* Baud Rate Divisor */
#define PARITY_DISABLED	     0x00
#define PARITY_ENABLED       0x08
#define BITS_5               0x00  /*  5 Bits per Character  */
#define	BITS_6 				 0x01  /*  6 Bits per Character  */
#define BITS_7               0x02  /*  7 Bits per Character  */
#define	BITS_8      		 0x03  /*  8 Bits per Character  */


/* Parametros para las interrupciones */
#define DATA_IN_BUFFER_INTERRUPT    0x01
#define	BYTE1						0x01
#define	BYTE4						0x41
#define	BYTE8						0x81
#define	BYTE14						0xC1
#define BYTERESET                                       0x71
/* Constantes de interaccion SERIAL   */
#define START_CONV					0x10
#define END_CONV				    0x11

#define OUT2                        0x08

/* Declaracion de funciones */
int
uartInit(short serialPort,int baudRate,unsigned char stopBit,unsigned char parity,unsigned char bitsPerChar,unsigned char ierConf,unsigned char bytesInBufferInt);
char   uartRead(int serialPort );

void
uartWrite(int port, int data );

char
serialRead(int serialPort);

void setSerialParams(void);
#endif /*SERIAL_H_*/
